<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,user-scalable=no">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/lib/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="/js/vue/vue.min.js"></script>
    <script type="text/javascript" src="/lib/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/laypage/1.2/laypage.js"></script>
</head>
<body>

<form class="layui-form" action="" style="margin-top: 30px" >
    <div class="layui-form-item">
        <label class="layui-form-label">角色名称</label>
        <input type="text" id="cid" th:value="${session.chara.id}" hidden="hidden"  >
        <div class="layui-input-block" style="width: 200px;height: 40px">
            <input type="text" id="chname" name="username"  lay-verify="username" placeholder="角色名称"  th:value="${session.chara.chName}"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">角色描述</label>
        <input type="hidden" th:value="${session.chara.chDetail}" id="exerate">
        <div class="layui-input-block"  style="width: 300px;height: 150px">
            <textarea placeholder="角色描述" id="roledec" class="layui-textarea" ></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn"  lay-submit="" lay-filter="xiugai">修改</button>

        </div>
    </div>
</form>
<script>


</script>
<script>
    layui.use(['form','jquery'],function () {
        var form = layui.form;
        var $ = layui.jquery;
        var fuzhi = function () {
            var v = $("#exerate").val();
            $("#roledec").html(v);
        }
        fuzhi();
        form.render();
        form.on('submit(xiugai)', function (data) {
            console.log(data.elem)
            console.log(data.form)
            console.log(data.field)

            alert($("#cid").val())
                $.ajax({
                    url:'/systemsetup/chara-manger/subchara',
                    type:'GET',
                    data:{
                        chName:$("#chname").val(),
                        chDetail:$("#roledec").val(),
                        id:$("#cid").val(),
                    },
                    success:function (rest) {
                        alert(rest)
                        if (rest==true){
                            parent.layer.msg('添加成功',{time:2000,icon:1});
                        }else {
                            parent.layer.msg("服务器繁忙请稍后再试",{time:2000,icon:2});
                        }
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.getUserPageList();
                    }
                })
                return false;

        })
    })
</script>
</body>
</html>